<% layout('/layouts/default.html', {title: '考核任务指标表管理', libs: ['dataGrid','fileupload','validate']}){ %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-body">
            <#form:form id="searchForm" model="${dcSupExamSumQuotaInfo!}" action="${ctx}/quota/dcSupExamSumQuotaInfo/listDetailFileData?sumQuotaId=${dcSupExamSumQuotaInfo.sumQuotaId}&quotaGroup=2&exameOrg=${dcSupExamSumQuotaInfo.gradeOrg}" method="post" class="form-inline "
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize!10}" data-order-by="${parameter.orderBy}">
            </#form:form>
            <div style="float: right;">
                <a href="#"  id="examine" onclick="auditPassed()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("审核通过")}"><i class="fa fa-check">审核通过</i></a>
                <a href="#"  id="retreat" onclick="auditNoPassed()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("退回")}"><i class="fa fa-reply-all">退回</i></a>
                <a href="#"  id="urge" onclick="urgeHandle()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee;margin-left: 10px" title="${text("催办")}">催办</a>
            </div>
        </div>

        <div class="box-body">
            <div id="xizhe" style="padding-bottom: 8px"><span style ="text-decoration:underline;font-size: 20px;color: #30bbbb">单项指标细则</span></div>
            <table id="dataGrid"></table>
            <div id="dataGridPage"></div>
        </div>
    </div>
</div>
<% } %>
<script src="${ctxStatic}/m/js/total.js?${_version}"></script>
<script>
    //获取通知标题
    var examTitle=`${dcSupExamQuota.examTitle}`;
    var fileStatus= `${dcSupExamSumQuotaInfo.fileStatus}`;
    $(function (){
        let data={
            searchForm: $("#searchForm"),
            columnModel: [
                {header:'${text("目标内容")}', name:'ids',  hidden:true},
                {header:'${text("目标内容")}', name:'quotaContent',  width:200, align:"left"},
                {header:'${text("被考核单位")}', name:'orgName',  width:200, align:"left"},
                {header:'${text("上传细则")}', name:'fileuploadId', width:250,align:"center",
                    editable: true, edittype: "custom", editoptions: {
                        custom_element: function(val, editOptions) {
                            return js.template('fileuploadTpl', {
                                id: 'fileupload_'+editOptions.id, title: '区域选择',
                                bizKey: val, bizType: 'dcSupExamSumQuotaInfo_file', cssClass: '', readonly: true
                            });
                        }
                    },unformat: function(val, obj, cell){
                        return $('#fileupload_'+obj.rowId+'_fileuploadId', cell).val();}
                },
            ],
            editGrid: true,
            emptyDataHint: true,
            showFooter: false, // 是否显示底部合计行
            // 加载成功后执行事件
            ajaxSuccess: function(data){
                refreshZpCount()
                window.parent.change(`${dcSupExamSumQuotaInfo.gradeOrg}`,fileStatus);
            }
        }
        if(examTitle.length==0){
            data.editGrid=false;
        }
        if(fileStatus=='1'){
            data.editGrid=false;
        }
        if(fileStatus=='3'){
            data.editGrid=false;
        }
        // 初始化DataGrid对象
        $('#dataGrid').dataGrid(data);
    })
    $(function (){
        if(fileStatus=='1'){
            $("#examine").css("display","none");
            $("#retreat").css("display","none");
            $("#urge").css("display","inline");
        }else if(fileStatus=='2'){
            $("#examine").css("display","inline");
            $("#retreat").css("display","inline");
            $("#urge").css("display","none");
        }else {
            $("#examine").css("display","none");
            $("#retreat").css("display","none");
            $("#urge").css("display","none");
        }
    })

    function urgeHandle(){
        js.loading();
        js.layer.open({
            type: 2,
            title: ['催办'],
            area: ['800px', '400px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/targetAudit/cuibanPageXZ?id=${dcSupExamQuota.examId}&org=${dcSupExamQuota.createOrg}",
            btn1: function (index, layero) {
            },
            success: function (data) {
                js.closeLoading(0, true);
            },
            end:function () {

            }
        });
    }
    //催办功能
    // function urgeHandle() {
    //     var gradeOrg=`${dcSupExamSumQuotaInfo.gradeOrg}`;
    //     js.confirm("是否催办细则报送？", {
    //         url: '${ctx}/targetAudit/urgeInformation',
    //         data: {
    //             "createOrg":gradeOrg,
    //             "remarks":"细则报送",
    //             "examTitle":examTitle,
    //         },
    //         callback: function(data){
    //             js.showMessage(data.message);
    //         },
    //         dataType: 'json',
    //         async: false, message: '正在催办...',
    //         shadeClose: true }
    //     );
    // }

    //审核通过
    function auditPassed(){
        js.confirm("您确定要审核通过吗？该操作不可恢复！", {
            url: '${ctx}/targetAudit/littleAuditIndex',
            data: {'sumQuotaId':`${dcSupExamSumQuotaInfo.sumQuotaId}`,'quotaGroup':'2','exameOrg':`${dcSupExamSumQuotaInfo.gradeOrg}`},
            callback: function(data){
                if (data.result=="true"){
                    //审核通过按钮
                    $("#btnPassed").css("display","none");
                    //退回按钮
                    $("#btnBack").css("display","none");
                    js.showMessage(data.message);
                    window.parent.orgChange(`${dcSupExamSumQuotaInfo.gradeOrg}`,'4');
                }else {
                    js.showMessage(data.message);
                }
            },
            dataType: 'json',
            async: false, message: '正在提交...',
            shadeClose: true }
        );
    }

    //审核退回
    function auditNoPassed() {
        js.confirm("您确定要退回【"+examTitle+"】细则报送吗？该操作不可恢复！", {
            url: '${ctx}/targetAudit/litteSendBack',
            data: {'sumQuotaId':`${dcSupExamSumQuotaInfo.sumQuotaId}`,'quotaGroup':'2','exameOrg':`${dcSupExamSumQuotaInfo.gradeOrg}`},
            callback: function(data){
                js.showMessage(data.message);
                window.parent.orgChange(`${dcSupExamSumQuotaInfo.gradeOrg}`,'3');
            },
            dataType: 'json',
            async: false, message: '正在退回...',
            shadeClose: true }
        );
    }

</script>
<script id="fileuploadTpl" type="text/template">//<!--<div>
<#form:fileupload id="{{d.id}}" bizKey="{{d.bizKey}}" bizType="{{d.bizType}}" uploadType="all"
	class="{{d.cssClass}}" maxUploadNum="1"  isMini="true" preview="true" readonly="{{d.readonly}}"/>
</div>//--></script>